﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SuperORM;
using System.Data;


public partial class CKQBG : System.Web.UI.Page
{
    public string PROJECT_ID = "";
    public string WORKFLOWID = "";
    public string JIEDIANSERILS = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        ISession session = Session["session"] as ISession;
        if (session != null)
        {
            PROJECT_ID = Request["PROJECT_ID"];
            WORKFLOWID = Request["WORKFLOWID"];
            JIEDIANSERILS = Request["JIEDIANSERILS"];
            if (!Page.IsPostBack)
            {
                string hjid = Helper.CommonHelper.GetFieldValueBySQL("ERPWORKFLOWJIEDIAN", "ID", "workflowid=" + WORKFLOWID + " and jiedianserils='" + JIEDIANSERILS + "'");
                if (hjid != null && hjid != string.Empty && hjid != "")
                {
                    ZWL.BLL.ERPWorkFlowJieDian jiedian = new ZWL.BLL.ERPWorkFlowJieDian();
                    jiedian.GetModel(int.Parse(hjid));
                    if (jiedian.NextJieDianSerils == null || jiedian.NextJieDianSerils == "" || jiedian.JieDianAddr == "结束")
                    {
                        FlowNextButton.ImageUrl = "../../myimages/banjie.png";
                        FlowNextButton.ToolTip = "办结";
                    }

                }
            }
        }
    }

    protected void FlowNextButton_Click(object sender, ImageClickEventArgs e)
    {
        string hjid = Helper.CommonHelper.GetFieldValueBySQL("ERPWORKFLOWJIEDIAN", "ID", "workflowid=" + WORKFLOWID + " and jiedianserils='" + JIEDIANSERILS + "'");
        if (hjid != null && hjid != string.Empty && hjid != "")
        {
            ZWL.BLL.ERPWorkFlowJieDian jiedian = new ZWL.BLL.ERPWorkFlowJieDian();
            jiedian.GetModel(int.Parse(hjid));
            if (jiedian.JieDianAddr == "结束" || jiedian.NextJieDianSerils == null || jiedian.NextJieDianSerils == "")
            {
                FlowNextButton.Visible = false;
                FlowNextButton.ImageUrl = "../../myimages/banjie.png";
                string prjid = Helper.CommonHelper.GetFieldValueBySQL("ERPXMLB", "ID", "PROJECT_ID='" + PROJECT_ID + "' and workflowid=" + WORKFLOWID + " and jiedianserils='" + JIEDIANSERILS + "' and yxbs=1");
                if (prjid != null && prjid != string.Empty && prjid != "")
                {
                    ZWL.BLL.ERPXMLB lb = new ZWL.BLL.ERPXMLB();
                    lb.GetModel(int.Parse(prjid));
                    lb.ID = int.Parse(prjid);
                    lb.YXBS = 0;
                    lb.Update();
                    Response.Redirect("../../Common/ProjectListInner.aspx");
                }
            }
            else
            {
                Response.Redirect("../../Common/FlowNext.aspx?PROJECT_ID=" + PROJECT_ID + "&WORKFLOWID=" + WORKFLOWID + "&JIEDIANSERILS=" + JIEDIANSERILS);
            }
        }

    }
}